import {defineStore} from "pinia";
import {reqHospitalDetail,reqDepartment} from '@/api/hospital'
import type {HospitalDetailResponseData,HospitalDetail,DepartmentResponseData,DepartmentArr} from "@/api/hospital/type";
import type {Detail} from './interface'

const useDetailStore=defineStore('Detail',{
	state:():Detail=>({
		// 医院详情数据
		hospitalData: ({} as HospitalDetail),
		// 科室数据
		departmentArr: []
	}),
	actions:{
		// 获取医院详情
		async getHospitalDetail(hoscode:string){
			let result:HospitalDetailResponseData = await reqHospitalDetail(hoscode)
			if (result.code===200){
				this.hospitalData=result.data
			}
		},
		// 获取科室数据
		async getDepartment(hoscode:string){
			let result:DepartmentResponseData = await reqDepartment(hoscode)
			if (result.code===200){
				this.departmentArr=result.data
			}
		}
	},
	getters:{},
})


export default useDetailStore